home *** CD-ROM | disk | FTP | other *** search
/ Floppyshop 2 / Floppyshop - 2.zip / Floppyshop - 2.iso / art&graf.ix / art-0015 / flicker / prim.c < prev    next >
C/C++ Source or Header  |  1997-04-16  |  4KB  |  221 lines

  1.  
  2. #define EDITOR
  3.  
  4. #include <aline.h>
  5. #include <osbind.h>
  6. #include "flicker.h"
  7.  
  8. #define REPLACE 1
  9. #define XOR    2
  10.  
  11.  
  12. extern struct aline *aline;
  13. extern WORD handle;
  14.  
  15. char gemctable[16] = 
  16.     {
  17.     0, 2, 3, 6, 4, 7, 5, 8, 9, 0xa, 0xb, 0xe, 0xc, 0xf, 0xd, 1,
  18.     };
  19.  
  20. WORD bitmasks[16] = {
  21.     0x8000, 0x4000, 0x2000, 0x1000,
  22.     0x800, 0x400, 0x200, 0x100,
  23.     0x80, 0x40, 0x20, 0x10,
  24.     0x8, 0x4, 0x2, 0x1,
  25.     };
  26.  
  27.  
  28.  
  29. get_cmap(cmap)
  30. register WORD *cmap;
  31. {
  32. register int i;
  33.  
  34. for (i=0; i<16; i++)
  35.     *cmap++ = Setcolor(i, -1);
  36. }
  37.  
  38. draw_frame(color, x0, y0, x1, y1)
  39. register int color, x0, y0, x1, y1;
  40. {
  41. hline(y0, x0, x1, color);
  42. hline(y1, x0, x1, color);
  43. vline(x0, y0, y1, color);
  44. vline(x1, y0, y1, color);
  45. }
  46.  
  47.  
  48. WORD solid[] = {0xffff, 0xffff, 0xffff, 0xffff,
  49.          0xffff, 0xffff, 0xffff, 0xffff};
  50.  
  51. set_acolor(color)
  52. register WORD color;
  53. {
  54. register struct aline *a = aline;
  55.  
  56. if (color & (1<<3) )
  57.     a->colbit3 = 1;
  58. else
  59.     a->colbit3 = 0;
  60. if (color & (1<<2) )
  61.     a->colbit2 = 1;
  62. else
  63.     a->colbit2 = 0;
  64. if (color & (1<<1) )
  65.     a->colbit1 = 1;
  66. else
  67.     a->colbit1 = 0;
  68. if (color & 1)
  69.     a->colbit0 = 1;
  70. else
  71.     a->colbit0 = 0;
  72. }
  73.  
  74. getdot(x, y)
  75. int x, y;
  76. {
  77. aline->ptsin = &x;    /*hope x and y on stack in correct order... */
  78. return(aget());
  79. }
  80.  
  81. hline(y, x1, x2, color)
  82. WORD color, y, x1, x2;
  83. {
  84. colblock(color, x1, y, x2, y);
  85. }
  86.  
  87. vline(x, y1, y2, color)
  88. int color, x, y1, y2;
  89. {
  90. colblock(color, x, y1, x, y2);
  91. }
  92.  
  93. set_solid_line()
  94. {
  95. register struct aline *a = aline;
  96.  
  97. set_acolor(ccolor);
  98. a->lnmask = 0xffff;
  99. a->wmode = REPLACE;  /*xor*/
  100. }
  101.  
  102. set_xor_line()
  103. {
  104. register struct aline *a = aline;
  105.  
  106. set_acolor(15);
  107. a->lnmask = 0xffff;
  108. a->wmode = XOR;  /*xor*/
  109. }
  110.  
  111. line(x1, y1, x2, y2)
  112. WORD x1, y1, x2, y2;
  113. {
  114. register struct aline *a = aline;
  115.  
  116. a->x1 = x1;
  117. a->y1 = y1;
  118. a->x2 = x2;
  119. a->y2 = y2;
  120. aaline();
  121. }
  122.  
  123. floodfill(x, y, color)
  124. int x, y, color;
  125. {
  126. if (getdot(x, y) == color)    /* avoid taking a long time to do nothing */
  127.     return;    
  128. vsf_color(handle, gemctable[color]);
  129. vsf_interior(handle, 1 /* solid */ );
  130. v_contourfill(handle, x, y, -1);
  131. }
  132.  
  133. polyfill( points, count, color)
  134. WORD *points;
  135. WORD count, color;
  136. {
  137. vsf_color(handle, gemctable[color]);
  138. vsf_interior(handle, 1 /* solid */ );
  139. v_fillarea(handle, count, points);
  140. }
  141.  
  142. colblock(color, x1, y1, x2, y2)
  143. WORD color;
  144. register WORD x1, y1, x2, y2;
  145. {
  146. register struct aline *a = aline;
  147.  
  148. if (y2 < 0 || y1 >= YMAX)
  149.     return;
  150. if (x2 < 0 || x1 >= XMAX)
  151.     return;
  152. if (y1 < 0)
  153.     y1 = 0;
  154. if (x1 < 0)
  155.     x1 = 0;
  156. if (x2 >= XMAX)
  157.     x2 = XMAX-1;
  158. if (y2 >= YMAX)
  159.     y2 = YMAX-1;
  160. set_acolor(color);
  161. a->wmode = REPLACE;  
  162. a->patptr = solid;
  163. a->x1 = x1;
  164. a->y1 = y1;
  165. a->x2 = x2;
  166. a->y2 = y2;
  167. a->xmincl = aline->ymincl = 0;
  168. a->xmaxcl = XMAX;
  169. a->ymaxcl = YMAX;
  170. acblock();
  171. }
  172.  
  173.  
  174. colrop(color, x, y, width, height)
  175. int color, x, y, width, height;
  176. {
  177. register struct aline *a = aline;
  178.  
  179. set_acolor(color);
  180. a->wmode = REPLACE;  
  181. a->patptr = solid;
  182. a->x2 = a->x1 = x;
  183. a->y2 = a->y1 = y;
  184. a->x2 += width;
  185. a->y2 += height;
  186. a->xmincl = aline->ymincl = 0;
  187. a->xmaxcl = XMAX;
  188. a->ymaxcl = YMAX;
  189. acblock();
  190. }
  191.  
  192. /* set up things so draw on buffer (invisible) screen */
  193. draw_on_buffer()
  194. {
  195. Setscreen(cscreen = bscreen, -1L, -1);
  196. }
  197.  
  198. /* set up things so draw on visible screen */
  199. draw_on_screen()
  200. {
  201. Setscreen(cscreen = pscreen, -1L, -1);
  202. }
  203.  
  204. /* just copy buffer to screen */
  205. buf_to_screen()
  206. {
  207. copy_screen(bscreen, pscreen);
  208. }
  209.  
  210. undo_to_buf()
  211. {
  212. copy_screen(screens[screen_ix], bscreen);
  213. }
  214.  
  215. /* expand part of buffer to visible screen ... zoom x 4 */
  216. zbuf_to_screen()
  217. {
  218. zoom(bscreen, pscreen, zoomx, zoomy);
  219. }
  220.  
  221.